package com.yanqu.road.server.cmd.activity.dunhuangshiku;

import com.yanqu.road.entity.enums.eLogMoneyType;
import com.yanqu.road.pb.dunhuangshiku.DunHuangShiKuProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @Description
 * @Author cwq
 * @Data 2021/4/19 18:05
 */
@Cmd(code = GameProtocol.S_DUN_HUANG_SHI_KU_RECEIVE_MURAL_REWARD_FROM_CROSS, desc = "敦煌石窟领取壁画奖励 跨服返回区服 协议")
public class DunHuangShiKuReceiveMuralRewardFromCrossCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        DunHuangShiKuProto.DunHuangShiKuReceiveMuralRewardRespMsg req = DunHuangShiKuProto.DunHuangShiKuReceiveMuralRewardRespMsg.parseFrom(packet.getBytes());
        ret = req.getRet();
        if(ret == 0){
            // 加道具
            CurrencyModule module = player.getModule(CurrencyModule.class);
            module.addCurrency(req.getReward(), eLogMoneyType.DunHuangShiKu, eLogMoneyType.DunHuangShiKuMuralReward);
        }
        player.sendPacket(ClientProtocol.U_DUN_HUANG_SHI_KU_RECEIVE_MURAL_REWARD, req.toBuilder());
    }

    @Override
    public void sendData(GamePlayer player) {
    }
}
